/**
 * 公共方法对uni的再次封装
 */
import Vue from 'vue';

const WF = {};
function taskStateFormatter(value) {
    switch (value) {
        case 0: return "送达"; break;
        case 1: return "处理中"; break;
        case 2: return "已完成"; break;
        case 3: return "<em class='.em'>已锁定</em>"; break;
        case 66: return "<em class='.em'>沟通中</em>"; break;
    }
    return "未知";
}
function urgeTimesFormatter(v){
    var value =v||0;
    if (value == 0)
        return "<span class=\"badge badge-grey\">" + value + "</span>";
    if (value > 0 && value <= 2)
        return "<span class=\"badge badge-warning\">" + value + "</span>";
    if (value > 2)
        return "<span class=\"badge badge-danger\">" + value + "</span>";
}

function getWorkflowStatus($vm,status) {
	var that = $vm;
	//var tag = '<span class="tabbtn {0}">{1}</span>';
	var tag = '<span class="{0}"><i class="fa {1} bigger-120"></i>{2}</span>';
	var tag2 = '<span class="{0}"> {1}</span>';
	var text, style, lable;
	switch (status) {
		case 1:
			text = "草&nbsp;稿";
			style = "fa-file-text-o";
			lable = "label label-grey";
			break;
		case 2:
			text = "审批中";
			style = "fa-random";
			lable = "label label-success";
			break;
		case 3:
			text = "已完成";
			style = "fa-stop-circle";
			lable = "label label-info";
			break;
		case 4:
			text = "已挂起";
			style = "fa-pause-circle-o";
			lable = "label label-inverse";
			break;
		case 5:
			text = "驳回发起人";
			lable = "label label-danger";
			break;
		case 6:
			text = "退&nbsp;回";
			style = "fa-reply";
			lable = "label label-warning";
			break;
		case 99:
			text = "已作废";
			style = "fa-trash";
			lable = "label label-grey";
			break;
		case 100:
			text = "已删除";
			style = "fa-trash";
			lable = "label label-grey";
			break;
	}
	if (status == 5) {
		return Object.toStringFormat(tag2, lable, text);
	}
	return Object.toStringFormat(tag, lable, style, text);
}
WF.getWorkflowStatus=getWorkflowStatus;
WF.taskStateFormatter=taskStateFormatter;
WF.urgeTimesFormatter=urgeTimesFormatter;
if (!Vue.prototype.$WF) { 
	Vue.prototype.$WF = WF;
}

export default WF;
